package com.suixin.keyGenerator;

import org.apache.shardingsphere.core.strategy.keygen.SnowflakeShardingKeyGenerator;
import org.apache.shardingsphere.spi.keygen.ShardingKeyGenerator;

import java.util.Properties;

/**
 * @description:
 * @author: wujunhong
 * @create: 2020/06/01 22:30
 */
public class MyIdGenerator implements ShardingKeyGenerator {

    private static String MY_SHARDING_KEY_TYPE="MYID";

    private SnowflakeShardingKeyGenerator snow = new SnowflakeShardingKeyGenerator();

    @Override
    public Comparable<?> generateKey() {
        System.out.println("------------生成id--------------");
        return snow.generateKey();
    }

    @Override
    public String getType() {
        return MY_SHARDING_KEY_TYPE;
    }

    @Override
    public Properties getProperties() {
        return null;
    }

    @Override
    public void setProperties(Properties properties) {

    }
}
